package com.controller.manager;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.po.CookBeanW;
import com.service.manager.CookServiceW;

@Controller
@RequestMapping("/jsp")
public class CookController {
	
	@Resource(name="cookServiceImpW")
	private CookServiceW cookservice;
	
	@ResponseBody
	@RequestMapping(value="/getCookList")
	private List<CookBeanW> getCookList(CookBeanW cook,Integer page,Integer rows){
		
		cook.setPage((page-1)*rows);
		cook.setRows(rows);
		List<CookBeanW> list = cookservice.getCookListW(cook);
		int count = cookservice.getCookCountW(cook);
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("total",count);
		map.put("rows", list);
		return list;
	}
	
	@ResponseBody
	@RequestMapping(value="/updateCook")
	private int updateCook(CookBeanW cook){
		
		int result = cookservice.updateCookW(cook);
		return result;
	}
	
	@ResponseBody
	@RequestMapping(value="/delCookList")
	private int delCookList(String cookids){
		
		String[] cookarry = cookids.split(",");
		int result = cookservice.delCookListW(cookarry);
		return result;
	}
}
